package org.example.binding;

import org.example.session.SqlSession;

import java.lang.reflect.Proxy;

public class MapperProxyFactory<T> {

    private final Class<T> mapperClass;


    public MapperProxyFactory(Class<T> mapperClass) {
        this.mapperClass = mapperClass;
    }





    protected T newInstance(MapperProxy<T> mapperProxy) {
        return (T) Proxy.newProxyInstance(mapperClass.getClassLoader(),new Class[]{mapperClass},mapperProxy);
    }


    protected T newInstance(SqlSession sqlSession) {
        MapperProxy<T> proxy = new MapperProxy<>(mapperClass, sqlSession);
        return newInstance(proxy);
    }



}
